"""
 -*- coding: utf-8-*-
 @File: mgt_yaml.py
 @Author: chen
 @time: 2023/12/01/ 19:16
"""
import yaml


class YamlMgt:
    @classmethod
    def read(cls, file):
        """
        读取yaml文件中的数据
        :param file: 文件路径+文件名
        :return: 返回yaml文件的数据
        """
        with open(file, "r", encoding="utf8") as file_stream:
            datas = yaml.safe_load(file_stream)
        return datas

    @classmethod
    def write(cls, data, file):
        """
        将数据保存到yaml文件
        :param data: 要保存的数据
        :param file: 文件路径+文件名
        :return:
        """
        with open(file, "w", encoding="utf8") as file_stream:
            yaml.dump(data, file_stream)


if __name__ == '__main__':
    file01 = "../businesses/config/env_info.yaml"
    login_info = YamlMgt.read(file01)
    print(login_info["headers"])
    # YamlMgt.write(login_info,"../businesses/config/in.yaml")
